package fun.codefarmer.pm.service.Impl;

import fun.codefarmer.pm.mapper.EmployeeMapper;
import fun.codefarmer.pm.model.Employee;
import fun.codefarmer.pm.model.RespPageBean;
import fun.codefarmer.pm.service.EmployeeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @ ClassName EmployeeServiceImpl
 * @ Descriotion TODO
 * @ author  codeFarmer_z
 * @ 公众号：码农教程
 * @ Date 2022/5/21 21:49
 **/
@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Resource
    private EmployeeMapper employeeMapper;

    @Override
    public RespPageBean getEmployeeByPage(Integer page, Integer size, Employee employee, Date[] beginDateScope) {

        if (page != null && size != null) {
            page = (page -1) * size;
        }
        List<Employee> data =  employeeMapper.getEmployeeByPage(page, size,employee,beginDateScope);
        Long total = employeeMapper.getTotal(employee,beginDateScope);
        RespPageBean respPageBean = new RespPageBean();
        respPageBean.setData(data);
        respPageBean.setTotal(total);
        return respPageBean;
    }
    public int addEmps(List<Employee> list) {
        return employeeMapper.addEmps(list);
    }
}
